package com.ethan.validation;

import com.ethan.anno.State;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;


public class StateValidation implements ConstraintValidator</*给哪个注解提供校验规则*/State,/*校验的数据类型*/String> {
    /**
     *
     * @param s
     * @param constraintValidatorContext
     * @return 如果返回false校验不通过，true通过
     */
    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        //提供校验规则
        if (s == null){
            return false;
        }
        if (s.equals("已发布") || s.equals("草稿")){
            return true;
        }
        return false;
    }
}
